Skip to content

[DX-1122] Fix: replace flags with positional arguments for primary entity identifiers#361

Merged
sacOO7 merged 3 commits intomainfrom
fix/flags-with-arguments
Apr 22, 2026
Merged

[DX-1122] Fix: replace flags with positional arguments for primary entity identifiers#361
sacOO7 merged 3 commits intomainfrom
fix/flags-with-arguments

Conversation

@sacOO7
Copy link
Copy Markdown
Contributor

@sacOO7 sacOO7 commented Apr 21, 2026

  • Fixes https://ably.atlassian.net/browse/DX-1122
  • As per CLI Convention Docopt =>
    Positional arguments = the thing being acted on (uppercase NAME or <name>)
    Options/flags = modifiers of behavior (--flag, -f)
  • So, If a value answers "what is being created/deleted/acted on?" it should be a positional argument.
    and If it answers "how should the operation be performed?" it should be a flag.
  • The Ably CLI currently has inconsistencies where some commands use flags (--name, --channel, --location) for values that represent the primary object being acted upon, while sibling commands correctly use positional arguments for the same purpose.
Category Create Command Sibling Delete Command
Apps ably apps create --name "APP_NAME" ably apps delete "APP_NAME"
Rules ably apps rules create --name "chat" --persisted ably apps rules delete "chat"
Queues ably queues create --name "my-queue" ably queues delete "my-queue"

Commands changed

Command Flag removed New argument
apps create --name APP_NAME (required)
apps rules create --name RULE_NAME (required)
auth keys create --name KEY_NAME (required)
queues create --name QUEUE_NAME (required)
push channels list --channel CHANNEL_NAME (required)
push channels save --channel CHANNEL_NAME (required)
push channels remove --channel CHANNEL_NAME (required)
push channels remove-where --channel CHANNEL_NAME (required)
spaces locations set --location LOCATION (required)

Commands unchanged

Command Flag kept Reason
integrations create --rule-type (required) Enum-constrained value from fixed options (http|amqp|kinesis|...); not a primary entity
integrations create --source-type (required) Enum-constrained value; two positional args with similar enum semantics would be confusing, not a primary entity
push config set-fcm --service-account (required) File path configuration input, not the primary entity being acted upon

Summary

  • Convert 9 command flags (--name, --channel, --location) to positional arguments
    where the value identifies the primary entity being acted upon, following CLI conventions
    (docopt, POSIX §12, sibling command patterns)
  • Update all unit tests, E2E tests, examples, and parent topic index files to match
  • See REPLACE_FLAGS_WITH_ARGUMENTS.md for the full audit and rationale

Breaking changes

These are breaking changes for users passing --name, --channel, or --location.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli-web-cli Ready Ready Preview, Comment Apr 22, 2026 9:11am

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes the Ably CLI argument style by replacing certain “primary identifier” flags (e.g., --name, --channel, --location) with required positional arguments, aligning sibling commands with docopt/POSIX conventions and updating tests/docs accordingly.

Changes:

  • Convert primary entity identifiers from flags to required positional arguments across apps, rules, keys, queues, push channels, and spaces locations commands.
  • Update command implementations, help examples/topic index examples, and unit/E2E tests to use the new positional argument forms.
  • Adjust shared test helper documentation to reflect the new argument style.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/unit/commands/spaces/spaces.test.ts Updates spaces command test to pass location as a positional argument.
test/unit/commands/spaces/locations/set.test.ts Updates validation/functionality tests for spaces:locations:set to use positional location.
test/unit/commands/queues/create.test.ts Updates queue create tests to pass queue name positionally and removes --name from flag assertions.
test/unit/commands/push/channels/save.test.ts Updates push channel save tests to pass channel name positionally and drops --channel from flag assertions.
test/unit/commands/push/channels/remove.test.ts Updates push channel remove tests to pass channel name positionally and drops --channel from flag assertions.
test/unit/commands/push/channels/remove-where.test.ts Updates remove-where tests to require channel positional arg and drops --channel from flag assertions.
test/unit/commands/push/channels/list.test.ts Updates list tests to require channel positional arg and drops --channel from flag assertions.
test/unit/commands/auth/keys/create.test.ts Updates key create tests to pass key name positionally and updates missing-arg expectations.
test/unit/commands/apps/rules/create.test.ts Updates rules create tests to pass rule name positionally and drops --name from flag assertions.
test/unit/commands/apps/create.test.ts Updates apps create tests to pass app name positionally and updates missing-arg expectations.
test/helpers/standard-tests.ts Updates helper doc comment example to reflect positional args.
test/e2e/spaces/spaces-e2e.test.ts Updates spaces locations set E2E usage to pass location JSON positionally.
test/e2e/push/channels-e2e.test.ts Updates push channels E2E usage/validation to use positional channel arg.
test/e2e/control/control-api-workflows.test.ts Updates control API workflow E2E sequences to use positional names for create commands.
src/commands/spaces/locations/set.ts Removes --location flag; adds required positional location argument and updates examples/parsing.
src/commands/queues/index.ts Updates topic examples to show queues create with positional queue name.
src/commands/queues/create.ts Replaces required --name flag with required positional queueName argument and updates request construction.
src/commands/push/index.ts Updates topic example for push channels list to use positional channel argument.
src/commands/push/channels/save.ts Replaces required --channel flag with required positional channelName and updates output/logging.
src/commands/push/channels/remove.ts Replaces required --channel flag with required positional channelName and updates confirmation/logging.
src/commands/push/channels/remove-where.ts Replaces required --channel flag with required positional channelName and updates request params/logging.
src/commands/push/channels/list.ts Replaces required --channel flag with required positional channelName and updates request params/logging.
src/commands/push/channels/index.ts Updates push channels topic examples to use positional channel argument.
src/commands/auth/keys/index.ts Updates auth keys topic example to use positional key name.
src/commands/auth/keys/create.ts Replaces required --name flag with required positional keyName and updates logging/request.
src/commands/apps/rules/index.ts Updates apps rules topic examples to use positional rule name for create/update/delete.
src/commands/apps/rules/create.ts Replaces required --name flag with required positional ruleName and updates namespace creation payload.
src/commands/apps/create.ts Replaces required --name flag with required positional appName and updates logging/request.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/queues/index.ts
Comment thread src/commands/apps/create.ts
Comment thread test/unit/commands/apps/create.test.ts Outdated
@claude-code-ably-assistant
Copy link
Copy Markdown

Walkthrough

This PR standardises 9 commands to follow POSIX / docopt CLI conventions by converting --name, --channel, and --location flags into positional arguments wherever those values identify the primary entity being acted upon. The change eliminates an inconsistency where sibling commands (e.g. apps delete APP_NAME) already used positional args while their create counterparts required --name. All unit tests, E2E tests, and example strings are updated to match.

Changes

Area Files Summary
Commands src/commands/apps/create.ts, src/commands/apps/rules/create.ts, src/commands/auth/keys/create.ts, src/commands/queues/create.ts Replace --name flag with required positional appName / ruleName / keyName / queueName arg
Commands src/commands/push/channels/list.ts, save.ts, remove.ts, remove-where.ts Replace --channel flag with required positional channelName arg
Commands src/commands/spaces/locations/set.ts Replace --location flag with required positional location arg
Topic indexes src/commands/apps/rules/index.ts, src/commands/auth/keys/index.ts, src/commands/push/channels/index.ts, src/commands/push/index.ts, src/commands/queues/index.ts Update examples in parent topic files to reflect new positional syntax
Unit tests test/unit/commands/apps/create.test.ts, apps/rules/create.test.ts, auth/keys/create.test.ts, queues/create.test.ts, push/channels/*.test.ts, spaces/locations/set.test.ts, spaces/spaces.test.ts Remove --name / --channel / --location from all runCommand calls; update error-message assertions from Missing required flag to Missing 1 required arg
E2E tests test/e2e/control/control-api-workflows.test.ts, push/channels-e2e.test.ts, push/push-config-e2e.test.ts, spaces/spaces-e2e.test.ts Same flag-to-positional update for full-scenario tests
Test helpers test/helpers/standard-tests.ts Update JSDoc example in standardControlApiErrorTests interface
Docs / config AGENTS.md Document the flags-vs-positional convention and add Args.* scaffolding examples

Review Notes

  • Breaking change — any script or shell alias that passes --name, --channel, or --location to the affected commands will break. There is no deprecation shim.
  • queues create validation — the existing test for a missing name previously matched Missing required flag.*name; it now matches Missing 1 required arg. Worth double-checking the oclif error message wording is stable across versions.
  • spaces locations set--location accepted a JSON string as a flag value; it is now the second positional arg (SPACE_NAME LOCATION). Verify that shell quoting/escaping of JSON still works cleanly as a positional.
  • No new dependencies — purely a refactor of flag definitions and call sites.
  • E2E coverage — all four E2E suites are updated, but push/channels E2E (channels-e2e.test.ts) and the control-api workflow test are the main regression risk areas given the breadth of flag removal.

Copy link
Copy Markdown

@claude-code-ably-assistant claude-code-ably-assistant Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

The changes are mechanically correct and well-executed. All 9 command conversions follow the same pattern: Args.string() with camelCase name, required: true, and every flags.X reference updated to args.X. Unit tests, E2E tests, and examples are fully in sync.

One pre-existing issue: src/commands/queues/index.ts delete example shows a queue name (my-queue) but queues delete matches on queue ID (format: appAbc:us-east-1-a:foo per its own examples). This was misleading before the PR too, but now that create is corrected, delete stands out. Worth a follow-up fix.

Everything else looks good: camelCase arg names, Flags import correctly removed from spaces/locations/set.ts, standardFlagTests only checks help output so removing the old flags from those lists is safe, error assertions correctly updated to Missing 1 required arg, Copilot comments already addressed in follow-up commit, AGENTS.md updated with new convention. No blocking issues.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AGENTS.md Outdated
@sacOO7 sacOO7 changed the title Fix: replace flags with positional arguments for primary entity identifiers [DX-1122] Fix: replace flags with positional arguments for primary entity identifiers Apr 22, 2026
sacOO7 added 3 commits April 22, 2026 14:41
arguments on commands where the flag value represents the primary
entity being acted upon, aligning with CLI conventions (docopt, POSIX, sibling commands).
@sacOO7 sacOO7 force-pushed the fix/flags-with-arguments branch from a800f0b to fb9b7f7 Compare April 22, 2026 09:11
@sacOO7 sacOO7 merged commit bb21223 into main Apr 22, 2026
11 checks passed
@sacOO7 sacOO7 deleted the fix/flags-with-arguments branch April 22, 2026 09:24
sacOO7 added a commit to ably/docs that referenced this pull request Apr 22, 2026
… identifiers

Reflects ably/ably-cli#361 — converts --name, --channel, and --location
flags to positional arguments across 9 command docs: apps create,
apps rules create, auth keys create, queues create, push channels
list/save/remove/remove-where, and spaces locations set.
umair-ably added a commit that referenced this pull request Apr 23, 2026
…es/push/locations

Align e2e tests with the --name/--channel/--location -> positional-arg
refactor from #361.
umair-ably added a commit that referenced this pull request Apr 23, 2026
…es/push/locations

Align e2e tests with the --name/--channel/--location -> positional-arg
refactor from #361.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants